<!DOCTYPE html>
<html>
        <head>
                <title>SpeedPHP CodeBuilder</title>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        </head>
        <body>
                <script src="bootstrap/js/jquery.min.js"></script>
                <script src="bootstrap/js/bootstrap.js"></script>

                <!-- header -->
                <div class="navbar navbar-inverse" style="position: static;">
                        <div class="navbar-inner">
                                <div class="container">
                                        <a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-inverse-collapse">
                                                <span class="icon-bar"></span>
                                                <span class="icon-bar"></span>
                                                <span class="icon-bar"></span>
                                        </a>
                                        <a class="brand" href="#">CodeBuilder</a>
                                        <div class="nav-collapse collapse navbar-inverse-collapse">

                                                <ul class="nav pull-right">
                                                        <li><a href="<{spUrl c=CodeBuilder a=logout}>">Logout</a></li>
                                                </ul>
                                        </div><!-- /.nav-collapse -->
                                </div>
                        </div><!-- /navbar-inner -->
                </div>

                <!-- content -->
                <div class="container-fluid">
                        <div class="row-fluid">
                                <div class="span2">
                                        <ul class="nav nav-pills nav-stacked">
                                                <li><a href="#">Introduce</a></li>
                                                <li class="active"><a href="<{spUrl c=CodeBuilder a=genController}>">Controller</a></li>
                                                <li><a href="<{spUrl c=CodeBuilder a=genCURD}>">CURD</a></li>
                                                <li><a href="<{spUrl c=CodeBuilder a=genModel}>">Model</a></li>
                                        </ul>
                                        <!--Sidebar content-->
                                </div>
                                <div class="span10">
                                        <form action="<{spUrl c=CodeBuilder a=genControllerAction}>" method="post" class="form-horizontal">
                                                
                                                <div class="control-group">
                                                        <label class="control-label" for="inputEmail">请输入Controller类名：</label>
                                                        <div class="controls">
                                                                <input name="controllerName" type="text" />
                                                        </div>
                                                </div>

                                                <input type="hidden" name="genAction" value="preview" />

                                                <div class="control-group">
                                                        <div class="controls">
                                                                <input id="gen" type="button" class="btn btn-primary" value="生成" />
                                                                <input id="preview" type="button" class="btn" value="预览" />
                                                        </div>
                                                </div>
                                        </form>
                                        <!--Body content-->

                                        <!-- Preview -->
					<{if $tpl_preview == true}>
					<div class="row">
						<div class="span12">
							<{if $tpl_codeFile_overwrite == true}>
							<div class="alert"><strong>警告!</strong> 新生成的文件将覆盖已经存在的Controller文件。</div>
							<{/if}>
							<p class="text-success">将在以下位置生成代码：<{$tpl_codePath}></p>
						</div>
					</div>
					<div class="row">
						<div class="span12">
							<pre>
<{$tpl_codePreview|htmlspecialchars}>
							</pre>
						</div>
					</div>
					
					<{foreach from=$tpl_genTemplatePreview item=template}>
					<div class="row">
						<div class="span12">
							<{if $template['overwrite'] == true}>
							<div class="alert"><strong>警告!</strong> 新生成的文件将覆盖已经存在的模板文件。</div>
							<{/if}>
							<p class="text-success">将在以下位置生成模板：<{$template['path']}></p>
						</div>
					</div>
					<div class="row">
						<div class="span12">
							<pre>
<{$template['contents']|htmlspecialchars}>
							</pre>
						</div>
					</div>
					<{/foreach}>
					
					<{/if}>
					
					<!-- Gen -->
					<{if $tpl_gen == true}>
					<div class="row">
						<div class="span12">
							<{if $tpl_success > 0}>
							<p class="text-success">成功在以下位置生成代码：<{$tpl_codePath}></p>
							<{else}>
							<p class="text-error">以下位置生成代码失败：<{$tpl_codePath}> 请检查是否存在controller文件夹或controller文件夹是否有写入权限。</p>
							<{/if}>
							<{if $tpl_success_template != -1}>
							<p class="text-success">成功生成模板</p>
							<{else}>
							<p class="text-error">生成模板失败，请检查是否存在tpl文件夹或tpl文件夹是否有写入权限。</p>
							<{/if}>
						</div>
					</div>
					<{/if}>
                                </div>
                        </div>
                </div>
                <script>
                        (function($){
                                $('#preview').click(function(){
                                        $('[name="genAction"]').val('preview');
                                        $('form').submit();
                                });
                                
                                $('#gen').click(function(){
                                        $('[name="genAction"]').val('gen');
                                        $('form').submit();
                                });
                        })(jQuery);
                </script>
		
		<{if $tpl_preview == true || $tpl_gen == true}>
		<script>
			(function($){
				$('[name="controllerName"]').val('<{$tpl_controllerName}>');
			})(jQuery)
		</script>
		<{/if}>
        </body>
</html>
